<!--
 * @Author: your name
 * @Date: 2021-04-27 15:36:24
 * @LastEditTime: 2021-04-28 11:21:46
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \solaxcloud\src\views\overview-inverter\pvDetailModal.vue
-->
<template>
    <div class="pvDetailModal=mian-box">
        <el-dialog
        :title="'PV'+$t('js_detail')"
        :visible="visiblePv"
        width="800px"
        @close="$emit('update:visiblePv', false)"
        >
            <baseTable   row-key='sid' :data="dataRows" border  stripe  :column='column' :select='false' :hideDetail='true'>
            </baseTable>
        </el-dialog>
    </div>
</template>

<script>
import baseTable from '../../components/common/baseTableNew'
export default {
    components: {
        baseTable
    },  
    props: {
        visiblePv:{
            type:Boolean,
            default:false
        },
        pvDetailData:{
            type:Object,
            default:()=>{return {}}
        },
        pvDetailDataType:{
            type:Object,
            default:()=>{return {}}
        },
    },
    data() {
        return {
             column:[{
                title: 'PV',
                value: 'PV',
            },{
                title: 'PV'+this.$t('batteryAnalysis.v_change')+ ' \n (V)',
                value: 'vdc',
            },
            {
                title: 'PV'+this.$t('batteryAnalysis.a_change')+ ' \n (A)',
                value: 'idc',
                slot: 'idc',
            },
            {
                title: this.$t('index.solarPower')+ ' \n (W)',
                value: 'powerdc',
                slot: 'powerdc',
            }],
            dataRows:[]
        };
    },
    computed: {

    },
    watch: {
        pvDetailData:{
            handler(nv,ov){
                if(nv){
                    this.setTableData(nv,this.pvDetailDataType.pvCount)
                }
            },
            deep:true,
        }
    },
    created() {

    },
    mounted() {

    },
    methods: {
        setTableData(data,count){
            let list = []
            if(count && data){
                for(let i=1;i<count+1;i++){
                        let obj = {
                            PV:'PV'+i,
                            vdc:data['vdc'+i],
                            idc:data['idc'+i],
                            powerdc:data['powerdc'+i],
                        }
                    list.push(obj)
                }
            }
            this.dataRows = list
        }
    },
};
</script>

<style  lang="less" scoped>

</style>
